package main

import (
	"fmt"
	"go-glue.googlecode.com/hg/rlglue"
)

type BurpEnv int32

func (re *BurpEnv) EnvInit() string {
	return "sample task spec"
}
func (re *BurpEnv) EnvStart() rlglue.Observation {
	*re = 0
	return rlglue.NewObservation([]int32{1}, []float64{0.0 / 2.0, 1.0 / 2.0}, []byte{'a', 'b', 'c'})
}
func (re *BurpEnv) EnvStep(action rlglue.Action) (obs rlglue.Observation, r float64, t bool) {
	if *re < 5 {
		obs = rlglue.NewObservation([]int32{int32(*re)}, []float64{}, []byte{})
		r = 1
		(*re)++
		t = (*re) == 5
		return
	}
	obs = rlglue.NewObservation([]int32{173, -173, 2147483647, 0, -2147483648}, []float64{0.0078125, -0.0078125, 0.0, 0.0078125e150, -0.0078125e150}, []byte{'g', 'F', '?', ' ', '&'})
	r = -2
	t = false
	return
}
func (re *BurpEnv) EnvCleanup() {
}
func (re *BurpEnv) EnvMessage(message string) (reply string) {
	timesToPrint := int32(*re) % 3
	reply = message + "|"
	for i := int32(0); i < timesToPrint; i++ {
		reply += fmt.Sprintf("%d", *re) + "."
	}
	reply += "|" + message
	return
}
func main() {
	if err := rlglue.LoadEnvironment(new(BurpEnv)); err != nil {
		panic(err)
	}
}
